/**
 */
package moore.impl;

import moore.MoorePackage;
import moore.OutputConfiguration;
import moore.valueState;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>value State</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link moore.impl.valueStateImpl#getOuputValue <em>Ouput Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class valueStateImpl extends AbstractStateImpl implements valueState {
	/**
	 * The cached value of the '{@link #getOuputValue() <em>Ouput Value</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOuputValue()
	 * @generated
	 * @ordered
	 */
	protected OutputConfiguration ouputValue;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected valueStateImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MoorePackage.Literals.VALUE_STATE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OutputConfiguration getOuputValue() {
		if (ouputValue != null && ouputValue.eIsProxy()) {
			InternalEObject oldOuputValue = (InternalEObject)ouputValue;
			ouputValue = (OutputConfiguration)eResolveProxy(oldOuputValue);
			if (ouputValue != oldOuputValue) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MoorePackage.VALUE_STATE__OUPUT_VALUE, oldOuputValue, ouputValue));
			}
		}
		return ouputValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OutputConfiguration basicGetOuputValue() {
		return ouputValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOuputValue(OutputConfiguration newOuputValue, NotificationChain msgs) {
		OutputConfiguration oldOuputValue = ouputValue;
		ouputValue = newOuputValue;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MoorePackage.VALUE_STATE__OUPUT_VALUE, oldOuputValue, newOuputValue);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOuputValue(OutputConfiguration newOuputValue) {
		if (newOuputValue != ouputValue) {
			NotificationChain msgs = null;
			if (ouputValue != null)
				msgs = ((InternalEObject)ouputValue).eInverseRemove(this, MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR, OutputConfiguration.class, msgs);
			if (newOuputValue != null)
				msgs = ((InternalEObject)newOuputValue).eInverseAdd(this, MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR, OutputConfiguration.class, msgs);
			msgs = basicSetOuputValue(newOuputValue, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MoorePackage.VALUE_STATE__OUPUT_VALUE, newOuputValue, newOuputValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MoorePackage.VALUE_STATE__OUPUT_VALUE:
				if (ouputValue != null)
					msgs = ((InternalEObject)ouputValue).eInverseRemove(this, MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR, OutputConfiguration.class, msgs);
				return basicSetOuputValue((OutputConfiguration)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MoorePackage.VALUE_STATE__OUPUT_VALUE:
				return basicSetOuputValue(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MoorePackage.VALUE_STATE__OUPUT_VALUE:
				if (resolve) return getOuputValue();
				return basicGetOuputValue();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MoorePackage.VALUE_STATE__OUPUT_VALUE:
				setOuputValue((OutputConfiguration)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MoorePackage.VALUE_STATE__OUPUT_VALUE:
				setOuputValue((OutputConfiguration)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MoorePackage.VALUE_STATE__OUPUT_VALUE:
				return ouputValue != null;
		}
		return super.eIsSet(featureID);
	}

} //valueStateImpl
